# json
# import json
#
# # Python 字典类型转换为 JSON 对象
# data = {
#     'no': 1,
#     'name': 'Runoob',
#     'url': 'http://www.runoob.com'
# }
#
# json_str = json.dumps(data)
# print("Python 原始数据：", repr(data))
# print("JSON 对象：", json_str)
#
# originData = json.loads(json_str)
# print(originData)
# # 如果你要处理的是文件而不是字符串，你可以使用 json.dump() 和 json.load() 来编码和解码JSON数据

# 日期和时间

# import time
# import math
#
# t1 = time.time()
# # 时间戳
# print(t1)
# # 格式化
# print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
#
# time.sleep(3)
#
# t2 = time.time()
# print(math.ceil((t2 - t1) * 1000), "ms")

# pip3 install requests
# import requests
#
# # 发送请求
# x = requests.get('https://www.runoob.com/')
#
#
# # 返回网页内容
# print(x.text)


# 爬虫

# import urllib.request
#
# url = "https://search.jd.com/Search?keyword=%E6%89%8B%E6%9C%BA"
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
# }
#
#
#
# # 创建一个request
# request = urllib.request.Request(url=url, headers=headers)
#
# # 发起request获取响应
# response = urllib.request.urlopen(request)
#
# # 设置解码
# content = response.read().decode("utf-8")
#
# print(content)
#
# with open("D:\\ip.html", "w", encoding="utf-8") as fp:
#     fp.write(content)


# pip3 install selenium
# https://registry.npmmirror.com/binary.html?path=chromedriver/
# https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
# selenium 操作浏览器
#
# from selenium import webdriver
# from bs4 import BeautifulSoup
#
# chrome = webdriver.Edge()
# chrome.get("https://www.starbucks.com.cn/menu/")
# source = chrome.page_source
#
# soup = BeautifulSoup(source, "html.parser")
#
# ss = soup.select(".page-menu-list li strong")
# for s in ss:
#     print(s.get_text())


# 元素定位 和交互
# from selenium import webdriver
# import time
# from selenium.webdriver.common.by import By
#
# edge = webdriver.Edge()
# edge.get("https://www.baidu.com")
#
# time.sleep(2)
#
# # 输入
# input = edge.find_element("id", "kw")
# input.send_keys("汽车")
#
# time.sleep(2)
#
# # 点击百度一下
# search = edge.find_element(by=By.ID, value="su")
# search.click()
#
# time.sleep(2)
#
# # 滑动到底部
# edge.execute_script("document.documentElement.scrollTop=100000")
#
# time.sleep(2)
#
# # 下一页
# next = edge.find_element(by=By.CLASS_NAME, value="n")
# next.click()
#
# time.sleep(2)
#
# # 浏览器回退
# edge.back()
#
# time.sleep(2)
#
# # 浏览器前进
# edge.forward()
#
# time.sleep(2)


# request
# pip3 install requests
# import requests

# response = requests.get("https://www.baidu.com")

# response.encoding = "utf-8"
# print(type(response))
# print(response)
# print(response.text)
# print(response.status_code)
# print(response.headers)
# print(response.url)


# import requests
#
# url = "https://www.baidu.com/s?"
#
# data = {
#     "wd": "武汉"
# }
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 '
#                   'Safari/537.36 ',
#     "Cookie": 'BIDUPSID=493ECB71888B6379AA89978D4F7D6BFF; PSTM=1685930600; BD_UPN=12314753; MCITY=-218%3A; BAIDUID=493ECB71888B637917D857A527966920:SL=0:NR=10:FG=1; sug=3; sugstore=0; ORIGIN=0; bdime=0; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BA_HECTOR=04ala1ag842g252101a42kak1ieis341p; delPer=0; BD_CK_SAM=1; PSINO=6; ZFY=mTImksNwNfsxeIQja2QGoo2ZEunO7xDT2ed0JkmLSsg:C; BAIDUID_BFESS=493ECB71888B637917D857A527966920:SL=0:NR=10:FG=1; shifen[2272411_53724]=1693021954; shifen[2272411_91638]=1693022090; BCLID=7775368665958344171; BCLID_BFESS=7775368665958344171; BDSFRCVID=-S0OJexroG0fYVnfgqgyMRVlDmKK0gOTDYLEOwXPsp3LGJLVFqiEEG0Ptf8gjM--J8jwogKKLgOTHULF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; BDSFRCVID_BFESS=-S0OJ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ytKI0RjQ0PriWbRM2MbgylRp8P3y0bb2DUA1y4vp0Jo03mTxoUJ25DnJjlCzqfCWMR-ebPRiWPb9QgbP2pQ7tt5W8ncFbT7l5hKpbt-q0x-jLTnhVn0MBCK0hI0ljj82e5PVKgTa54cbb4o2WbCQ-tcr8pcN2b5oQT8EWJjXKtbDWGOubfQs3n6vOIJTXpOUWfAkXpJvQnJjt2JxaqRC3tjEsq5jDh3Mb6ksM4FLexIO2jvy0hvcBn3cShnaXMjrDRLbXU6BK5vPbNcZ0l8K3l02V-bIe-t2XjQhDNtDt60jfn3aQ5rtKRTffjrnhPF3MpKfXP6-hnjy3bRhhxQ85J3aOtOE0ljSQ-uUyN3MWh3RymJ42-39LPO2hpRjyxv4QR_tQtoxJpOJ5JbMBqCEHlFWj43vbURvX--g3-7PWU5dtjTO2bc_5KnlfMQ_bf--QfbQ0hOhqP-jBRIEoK0hJC-2bKvPKITD-tFO5eT22-us2K3W2hcHMPoosIJIWqj_b4-LyfvuQq5Q3IjiaKJjBMbUoqRHXnJi0btQDPvxBf7p3j60Kl5TtUJMeCnTMxFVqfTbMlJyKMniBIv9-pnGBpQrh459XP68bTkA5bjZKxtq3mkjbPbDfn028DKuDTtajj3QeaRabK6aKC5bL6rJabC3Kf8xXU6q2bDeQN3hXl5X5DvD0-TzLfQSsb6oyT3JXp0vWtv4WbbvLT7johRTWqR4s4jYQfonDh83bG7MafuLHmLOBt3O5hvv8b3O3M7lXMKmDloOW-TB5bbPLUQF5l8-sq0x0bOte-bQXH_E5bj2qRCqVC3P; H_PS_PSSID=36546_39226_39223_39194_39199_39240_39233_26350_39239_39138_39224_39137_39100; COOKIE_SESSION=6496_1_7_9_4_11_1_0_7_7_1_1_8367_0_4_0_1693028590_1693020192_1693028586%7C9%23262820_97_1693020190%7C9; H_PS_645EC=b4a446p19BYJDRcTQ%2BJhTvYIcu0ZF8EZvbzPaf%2BN5usbjli2iNztGB34Bng; B64_BOT=1'
# }
#
# response = requests.get(url=url, params=data, headers=headers)
# response.encoding = 'utf-8'
# print(response.text)

# import requests
#
# url = 'http://fanyi.baidu.com/langdetect'
#
# data = {
#     "query": "快乐"
# }
#
# headers = {
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 '
#                   'Safari/537.36 ',
#     "Cookie": 'BIDUPSID=493ECB71888B6379AA89978D4F7D6BFF; PSTM=1685930600; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; MCITY=-218%3A; BAIDUID=493ECB71888B637917D857A527966920:SL=0:NR=10:FG=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BA_HECTOR=04ala1ag842g252101a42kak1ieis341p; delPer=0; PSINO=6; ZFY=mTImksNwNfsxeIQja2QGoo2ZEunO7xDT2ed0JkmLSsg:C; BAIDUID_BFESS=493ECB71888B637917D857A527966920:SL=0:NR=10:FG=1; BCLID=7775368665958344171; BCLID_BFESS=7775368665958344171; BDSFRCVID=-S0OJexroG0fYVnfgqgyMRVlDmKK0gOTDYLEOwXPsp3LGJLVFqiEEG0Ptf8gjM--J8jwogKKLgOTHULF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; BDSFRCVID_BFESS=-S0OJexroG0fYVnfgqgyMRVlDmKK0gOTDYLEOwXPsp3LGJLVFqiEEG0Ptf8gjM--J8jwogKKLgOTHULF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF=tbkD_C-MfIvDqTrP-trf5DCShUFstPjTB2Q-XPoO3KJtofQkb4JaytKI0RjQ0PriWbRM2MbgylRp8P3y0bb2DUA1y4vp0Jo03mTxoUJ25DnJjlCzqfCWMR-ebPRiWPb9QgbP2pQ7tt5W8ncFbT7l5hKpbt-q0x-jLTnhVn0MBCK0hI0ljj82e5PVKgTa54cbb4o2WbCQ-tcr8pcN2b5oQT8EWJjXKt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hhxQ85J3aOtOE0ljSQ-uUyN3MWh3RymJ42-39LPO2hpRjyxv4QR_tQtoxJpOJ5JbMBqCEHlFWj43vbURvX--g3-7PWU5dtjTO2bc_5KnlfMQ_bf--QfbQ0hOhqP-jBRIEoK0hJC-2bKvPKITD-tFO5eT22-us2K3W2hcHMPoosIJIWqj_b4-LyfvuQq5Q3IjiaKJjBMbUoqRHXnJi0btQDPvxBf7p3j60Kl5TtUJMeCnTMxFVqfTbMlJyKMniBIv9-pnGBpQrh459XP68bTkA5bjZKxtq3mkjbPbDfn028DKuDTtajj3QeaRabK6aKC5bL6rJabC3Kf8xXU6q2bDeQN3hXl5X5DvD0-TzLfQSsb6oyT3JXp0vWtv4WbbvLT7johRTWqR4s4jYQfonDh83bG7MafuLHmLOBt3O5hvv8b3O3M7lXMKmDloOW-TB5bbPLUQF5l8-sq0x0bOte-bQXH_E5bj2qRCqVC3P; H_PS_PSSID=36546_39226_39223_39194_39199_39240_39233_26350_39239_39138_39224_39137_39100; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1691638164,1691811358,1692842816,1693031349; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1693031349; ab_sr=1.0.1_MmNjNTgxYzlhZjhhMWZjZGJlY2U2M2E0MGQ5Y2VhZTU1NThiNTFhMWQ2YThmYjEyMzU5NjQ1MWQ1MzUxZjRiYmFmNjYzYzk0ZmI1N2NlYzY2ODRmYzZjZmRmMjM4NWUwMGQ1YmRkMTczYzZlY2E3YWE1OGFhYmUzNTc2NmExNDkzYTAwYTZmODAxYjhjZDE5ZTQzMzViNGYxZmZmNDVjZg=='
# }
#
# proxy = {
#     "http": "114.231.42.64:8888"
# }
# response = requests.post(url=url, data=data, headers=headers, proxies=proxy)
# print(response.text)



